package org.jrpc.base;

import org.jrpc.common.baen.RpcResponse;

import java.util.concurrent.SynchronousQueue;

/**
 * Created by Administrator on 2017/8/30.
 */
public class ResultResponse {
    private RpcResponse rpcResponse ;
    //    private String sign="";
    private Boolean wasSignalled = false;

    public ResultResponse() {
        rpcResponse = new RpcResponse();
    }

    public ResultResponse(RpcResponse rpcResponse) {
        this.rpcResponse = rpcResponse;
    }

    public RpcResponse getRpcResponse() {
        synchronized (this) {
//            if(!wasSignalled){
            while (!wasSignalled) {
                try {
                    this.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
//            }
        }
        return rpcResponse;
    }

    public void setRpcResponse(RpcResponse rpcResponse) {
        synchronized (this) {
            wasSignalled = true;
            this.notify();
        }
        this.rpcResponse = rpcResponse;
    }

}
